/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div>
      <div class="fixed-bar">
        <div class="item-title">
          <a class="back" href="javascript:history.back(-1)" title="返回列表">
            <i class="fa fa-arrow-circle-o-left"></i>
          </a>
          <div class="subject">
            <h3>财务管理 - 提现申请</h3>
            <h5>网站系统财务管理提现申请</h5>
          </div>
        </div>
      </div>
      <form :model="form" class="form-horizontal" id="handleposition" method="post">
        <div class="ncap-form-default">
          <dl class="row">
            <dt class="tit">
              <label>用户id</label>
            </dt>
            <dd class="opt">
              <a href="#" @click="getUser(form.user_id)">
                <p>{{form.user_id}}</p>
              </a>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>用户名</label>
            </dt>
            <dd class="opt">
              <p>{{form.nickname}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>用户平台余额</label>
            </dt>
            <dd class="opt">
              <strong class="red">{{form.user_money}}</strong> 元
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>冻结资金</label>
            </dt>
            <dd class="opt">
              <strong class="red">{{form.frozen_money}}</strong> 元
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>申请提现金额</label>
            </dt>
            <dd class="opt">
              <strong class="red">{{form.money}}</strong> 元
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>扣除手续费</label>
            </dt>
            <dd class="opt">
              <strong class="red">{{form.taxfee}}</strong> 元
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>实际到账金额</label>
            </dt>
            <dd class="opt">
              <strong class="red">{{form.money - form.taxfee}}</strong> 元
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>提现银行机构名称</label>
            </dt>
            <dd class="opt">
              <p>{{form.bank_name}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>提现账户号码</label>
            </dt>
            <dd class="opt">
              <p>{{form.bank_card}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>提现账户开户名</label>
            </dt>
            <dd class="opt">
              <p>{{form.realname}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>申请时间</label>
            </dt>
            <dd class="opt">
              <p>{{form.create_time_detail}}</p>
            </dd>
          </dl>

          <dl class="row">
            <dt class="tit">
              <label>状态</label>
            </dt>
            <dd class="opt">
              <template>
                <el-radio-group v-if="form.status != -2" v-model="form.status">
                  <el-radio :label="0">待审核</el-radio>
                  <el-radio :label="1">审核通过</el-radio>
                  <el-radio :label="-1">审核失败</el-radio>
                </el-radio-group>
                <el-radio v-if="form.status == -2" v-model="form.status" :label="-2">无效作废</el-radio>
              </template>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>备注</label>
            </dt>
            <dd class="opt">
              <el-input
                style="width: 280px;"
                type="textarea"
                :rows="2"
                placeholder="请输入内容"
                v-model="form.remark"
              ></el-input>
              <p class="err-msg" v-if="errResult.remark && !form.remark">{{errResult.remark}}</p>
            </dd>
          </dl>
          <dl class="row">
            <dt class="tit">
              <label>提现流程</label>
            </dt>
            <dd class="opt">
              <p>1:用户前台申请提现</p>
              <p>2:管理员审核通过</p>
              <p>3:进入财务待转款列表</p>
              <p>4:财务管理员给用户转账(转帐时自动扣除用户平台余额 )</p>
            </dd>
          </dl>
          <div class="bot" v-if="form.status != -2">
            <el-button type="primary" @click="onSubmit()" :loading="isLoading">确认提交</el-button>
          </div>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
import { getUserWithdrawals, updateUserWithdrawals } from "@/utils/api";
export default {
  data() {
    return {
      form: {},
      isLoading: false,
      errResult: { remark: null }
    };
  },
  created() {
    this.getUserWithdrawals();
  },
  methods: {
    onSubmit() {
      if (!this.form.remark) {
        this.$message.error("参数错误");
        this.errResult.remark = "备注不能为空";
        return;
      }
      var that = this;
      this.isLoading = true;
      updateUserWithdrawals(that.form).then(function(res) {
        if (res.status == 1) {
          that.$message.success({
            message: "保存成功",
            duration: 1000,
            onClose: function() {
              that.$router.push({
                name: "user_withdrawals"
              });
            }
          });
        } else {
          that.$message.error(res.msg);
        }
        that.isLoading = false;
      });
    },
    getUserWithdrawals() {
      var that = this;
      getUserWithdrawals({
        id: this.$route.params.id
      }).then(function(res) {
        that.form = res;
      });
    },
    getUser(id) {
      this.$router.push({
        name: "member_details",
        params: {
          user_id: id
        }
      });
    }
  }
};
</script>

<style scoped>
</style>
